fixed bugs in java code