I am trying to identify the variable that equals the rowmax variable, but am running into issues.

I have school district-level data that contains three variables indicating the percentage of students in the district receiving a certain instruction type: remote, in-person and hybrid. Each row is a unique district. I do the following:

Code:
egen max = rowmax(in_person remote hybrid)
gen inst_type = ""
replace inst_typ = "in_person" if max == in_person
replace inst_typ = "hybrid" if max == hybrid
replace inst_typ = "remote" if max == remote
Here's a table to illustrate:
district_id remote_pct hybrid_pct in_person_pct max inst_type
1 88.5 11.5 0 88.5 remote
2 11.5 77.8 5.1 77.8 ""
3 94.4 0 5.6 94.4 ""
4 23.1 74.1 2.8 74.1 ""
The variable max is correctly generated. The problem is that inst_type isn't modified the way I want. For each district, I am trying to indicate in which instruction mode most students participated. For example a district for which max==remote will indeed have the correct values but inst_type will be missing instead of inst_typ == "remote". What could I be doing wrong? Apologies if this is a rudimentary question, but I've been at this for over an hour. I am using STATA 16.

Thanks for the help.