Code Refactoring in views