another fixed sql bug