beginning of code restructuring