changed rD to rindex. group1 and group2 are used as signed ints