restructuring and debugging