Fixed grid coordinate detection

Correctly outputs the nearest coordinate for all points clicked.