refactoring Matcher.java