Refactored get_stories code.