Modified functionality to resolve variables on state change