I figured it out! I was trying to use variables that didnt actually exist, using "X" and "Y" rather than "[X]" and "[Y]", so it all works now.
so logic error after all :D