finished first 3 functions