fix all exceptions when tags do not exist

should be the final version for one thread programming