modified getTag function