restructing index.py