some boilerplate functionality to manage states