refactor mode