fixed bad array access