Hotfix for NoSuchElementException

Avoid NoSuchElementException checking availability of next element