Added best fit logic.