fix bugs in network layer