UPDATED SQL SCRIPT