fixed some embarrassing syntax and semantic mistakes