min out of loop