state handling goes into the library