IndexOutOfBoundsException when two groups don't have common parts