simplify state machine implementation