putting everything together in a console app, some small refactors along the way