modified for logging purposes