Algorithm on the map