porting #197 fix