Optimize rotateLeft and rotateRight