Adding code to java version