Fix out-of-bounds table access