Add bounds checking to input