[Tokenizer] move if context to methods allowing .write to be optimized