fixed bug in toLog function