added local scope to all loop constructs