move network logic to a helper class