refactored frontend to use the api