Update functions2.R

simplify function pred