Use Math.min to find the comparable length--much simpler!