Shortened some code in index.py