moved networking to main loop