fixing bad variable references