fix error handling in tag