Learning through failure