Update view.py

Remove duplicate code