added function 3 definition finaloutput()