wrote a setRotation function to replace some code mess