refactoring controllers and views