added the code for randomized search with comments