shit forgot to commit, refactoring main method