add code to complete the functions