reorganized code order