state machine done  needs testing