improved match.java