updated with logging.