fixes  #2867

Fixed and tested.

Please check.