Added som specs, restructured the mDet function for better readability.