bne should have applied to A, not X, but adding a cmp #$00 before makes the change less optimized than the existing.