Work on search

same as #609 for the master branch. closing the other one