Tidied up old search logic