Refactoring and add publishPermissionResult