built basic state machine