implemented streamlined array access and bounds checking