Array bounds overflow fix