refactors main