Refactored views.py