fix bulk_insert loop