How NASA accidentally found a way to make buildings safer during earthquakes