huge refactor to MVC architecture