iterate less to calculate reserved names

just a refactoring for fewer iterations