simplified variables and removed resets