modified tag query to avoid duplicates