added more function definitions.
Functions for med_model