Add more bounds checking