refactoring for app factories and api