move some variable outof loop in process()