fixed some scope and formatting issues pointed out by @mrclay