Refactoring modal transitions