fix for issue #159

fix for issue #159, the code was not correctly  checking.