Optimization of the refrigerant capacity in multiphase magnetocaloric materials