added IndexError to try/except clause