refactor hashtag-gathering code