cleanup view.py code to remove redundant parts