finished first two functions