tweaked so that it prints last result properly