fixed sql issue