Refactoring REST controller