Fixing small logic bug in #3655
Merge commit 'a35803f050f58a3df015a5f1961b94554d88b01b'