modified comments/logs
Fixed unintended global variables
Adjusted comment