Your state variable is initialised with zero. You have a default case in your switch that will handle state zero.