Updated java code