factor out consants; use safer string comparision order