Implemented fix to save and output data for the functions