Changed looping from for to block