modified for logging