moved the code chunk under for loop in routepacket function as Chris said