fix random impl race condition