How did Frederick respond to the defeat at Hanover