Directional Switching Mechanism of the Bacterial Flagellar Motor