refactored shared functions and ported social network sharing into library