Refactor search result creation: use map instead of forEach, further abstraction