main tagging functionality