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

Trying to implement the following code I had to make the following modification to be working.