optimize network code