Better array splicing for path matching