bug fix for calculating the correct position and angle