Fix typo, simplify loops.