move some functions around