Code refactored. Created separate classes for GridSearch and RandomSearch.