doing some refactoring to the rest api