Fix incorrect in-bounds check