Add bounds checking