added state machine for flash tool