AreValidCoordinates() refactured