access out of range bug fix