Java: Refactoring