added rotation calculation