sha: change loop condition to be tighter.