refactor rest endpoints