My algorithm was a little wrong.