combined functions.h and final.c
semi finalized final.c