updated sql queries