Refactor simple using Java