add some code for calculating the scattering state