Method to calculate position