Fixed Logical Errors In gotoCoordinate() function.

The errors where creating an infinite loop that cannot be stopped.