first stab at refactoring the backend API