properly check for parsing end