Now handles both positive and negative moves in X and Y.