restructuring the code