added more error handling in getTAG.