I'll add some more comments to this function in the next round.