pass function to addResource for nested resources