Refactor duplicate code getHeadlines