Implemented rotateTowards function