move some functions to rmisc