Refined the log fucntion so that it will now log a file every 2 seconds
with an average and updated the main for an example