update state before training