Array out of bound error while delete index from bytes32 array

this is the error while i was removing the key bytes32 value from the bytes32[] array.

ProviderError: Error: VM Exception while processing transaction: reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index)

bytes32[] myvalues;

function removeKey(bytes32 _hash)
public
{

    bytes32[] memory auxArray = new bytes32[](someArray.length-1);
    for(uint i = 0; i < someArray.length; i++) {
        if(someArray[i] != _hash) {
            auxArray[i] = someArray[i];
        }
    }
    someArray = auxArray;
}