full implementation of MDF