refactoring, rest impl