fix referencing wrong variable