fixed bug with coordinates and bug if a sensor is on the perimeter