Refactor try/except

Check length of list instead of catching IndexError