Rotation algorithm added