-added a check to see if the previous x or y position were the same
-need to fix scope of variables