Fixed a bug that resulted from confusing variable names.

@BrettASwift Could you take a look?