refactor diffusion in problem nine