fix logWrite function