updated sql script