add optimise_search function