refactored using a specific Position class for (x,y) coordinates