Fixed an error in position determination