fixed bug in sql requests