saving state value in the callback