add debug flag for logging details