Execute history function on every state change of options