Code refactoring of seach part