cleaned up diffuse sampling code