more fixes on searching logic query