move some functions to scripts