refactoring tagshandler