refactored the tags code