Fix termination condition for getNextExpr