Simplified code to replace tags with mask