reworked state diagram