refactoring index.py