implemented rotation with variable degrees, and refactored a little