Refactor to MVC