replace type code with state