Oh you're sometimes setting previous and sometimes just chaining states together directly. Either do it every time you make a new state in a sequence, or do it only once at the end. Doing it inconsistently makes the code confusing to read.