optimize algorithm
Add Random class unit test