Refactored version of mhwd