fixed index error in networks loop