Properly named variable inside block

Closes #9824.