state machine working
working (kinda) state manager with NaN handler