Add rotate algorithm