refactor spring code