move some functions out of a model-specific module