Refactor for following MVC.