changed function writeLog