refactoring code and views