Changed to MVC pattern