changed sql script slightly