some refactoring of massfuncs