Refactoring sharing function for resources