a bit of bounds checking