fixed bug in search

- [x] finish the code
- [x] gather feedback for my changes
- [ ] submit changes to the documentation


| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes
| Tests pass?   | none
| Fixed tickets | none
| Doc           | none