Restructuring the code as per design