todo: how to call callback only on state change?