Corrected loop to finding greatest diff