Refactored main
Refactored further. Completed user story #4.