construction of the phase_id vector