Fixed bug Ny changed to Nx in redidual loop.