added debug logging.