Created bestFit function