more robust. added logger.