Mistakes to Success: Learning and Adapting When Things Go Wrong