Bug fix to search method