refactoring in java code