improved loop and printing progress