Wrote and tested functions