fix random logic