Fix to log function