fixed up a number of SQL statement errors