remove useless code, adjust some code order