Averting group failures in collective-risk social dilemmas