Changed register variable names to avoid the reserved register name STATE