Refactored the code to find the coordinates of the top and left dots.