fixing min function error