modified the case when we just want the minimum amount of M