add a pair of missing braces
fix logical error
misc typo fix