make search work properly again after refactor, last commit introduced bugs