Updated the if condition to be more explicit and change the get

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    |  2.3+
| Fixed tickets | 

Trying to implement the following code I had to make the following modification to be working.