Fixed the network algorithm, swapped it into a method because clean code.