updated sql statement