updated lval_copy to handle user defined function values