Refined validation and search logic