change rotate logic by calculating time