fixed hopefully... state machine.