Refactored variable names and improved logging.