reformatted code, took out a state transition