refactor(main) reorder code