fix a bug in begin.optimize

@exps.shift remove the statements in begin, caused error.
don't shift, use @exps[i].