finished the first two functions