refactory the application to the MVC archtecture