refactor to centralize some apis in the app