Added code for throwing NoSuchElementExceptions