Refactoring for --mode