refactored underlying socket calls into a separate file