separate out minimization logic