Move illegal token name check into it's own function