Split search_query
Use case/when instead of chaining if