Replace type code with state