Refactor computeNewLocation