Refactoring up view code