Fix logic (Bug #13001).
Bug #12994: Fix logic