refactoring spring code