Code optimization

phase1