check for array bounds