Replacing the random function and making small changes to range traversal