code fix for Issue #1158

I tried to explain my fix into the comments of the Issue  #1158. Thanks