Updating code to work in network better