fixed table index is nil error