minor optimization: change for -> while in DistributedUtil