Fix IndexError when no result exists