Refactor getCoords method