1)big refinement of views.py for better python code style, 2)make the code easy to read