updated the rotate function