code the function