refactoring of getCoords functions