try to correct the computatino of prior residues to depend on state exited not entered