Some code refactor and a try of MVC approach