Getting correct coordinates or change direction