fix search, tidied up