Tagging logic revised