refactor(main): reorder code