optimize the codes.