refactoring Cloud App Function