edited to complete the functions