adding the function

still some errors