Refactor to MVC pattern complete