refactoring and new endpoints