Refactoring; correcter SQL-query for search query.