Added parameters for the current index and the coarse sequence's residue index to the extendMatch function