Fix lsmr loop and add debug print