refactor endpoints