Reorganized the Code