Fixed possible exception when a variable is out of bounds.