Added network function, a bit refactor