Slight java refactoring