minCoordinates function added