Refactoring of main, and extrapolation of methods into Utilities