Refactors to MVC structure