Fix bug in search engine code