fixed sql syntax problems