code cleaned and MVC restructured