Optimizing your legacy: the role of rebalancing in charitable giving