Reorganized the codes