update state and action