Refactor name checking into a separate function.