prototype of state function