implement the state API