move some code outsite a funciton