restructuring network code