fix bug in log function