fixed sql syntax errors