Refactored the program into MVC