fixed misused variable names causing crash