added repflag to stop overwriting rep data