Refactors main