java code and simplifications