bounds checking implemented