refactored out connection lib