Worked on restructuring the code