Renamed variables for clarity and added comments