cleaned up views.py code