new program flow
added state machine
timeout