add internal state handlers to clean up some code