fixed a bug with random assign