implementation of state struct