first pass with lookahead