code repetition with function `getLatitude`, could we refactor it to one function?