The mechanism of protein folding