cleaned up repeated code in views.py