refactored scattering to (hopefully) speed it up