Refactored the api app