move some functions out of initialization