Added option to save data to log file