output ordering bug fix