Added rotate algorithm