developing the MLR function with cross validation