wrote the functions