working on the Java version