Understanding the custom resource function code