Moved network logic into separate file