some bugs fixed in views.py