views code refactoring