fixed debug mode error in apply_stencil