Simplified the parseTag function