fix bug:id duplication and freeze in while