fixed sql check