Completed except for the last 4 functions