Fixed error checking in index.py