Add braces around while loop, some comments for scope