refactored code to use Spring Data for JPA