Refactored get_social_networks function