eliminated rand() which makes threads extremely slow