bug fix: wrong var name had been used in bound checking