Added array bounds check in table select - fixes #12