views.py refactored