view.py refactoring