refactor possibleMatches route handler based on stack overflow suggestion