fix calculating rotation