refactoring to MVC