updated sql creation code