Refactoring of Rest service