Fix use of incorrect variables