Help finishing State Machine Code