fixed main function in search