1/13 code. Finished basic state machine