Refactory of HomeController logic.