modified tag replace code