remove unnecessary cast to array and use `matches.add(result)`