finished the first function