added basic state machine