Rewrited the newdata function