code restructuring and documentation