Changing method for writing log (much more cleaner)