refactoring, renamed all occurrance of "type" to "tag"