fixed issues wiht sql