wrote the 2 functions