Bug #12994: Fix logic