refactor for cleaner main