achieved goal using 4 functions