Add proper error handling and remove logging.