fix bug when logging is enabled