bugfix in sql script