mode refactor