Fix loop issue with ddl