Handle the IndexError gracefully