reusable detagify function