Fixed infinite loop in while_scope