Refactoring Restful framework