refactor rotate