Changed to a more MVC structure