use local variable for storing debugging data

a better version for #1241