Fixed bounds checking code to work for test case from T-Square