refactored app and api