refactor REST api