almost finish translating to Java.