porting #178 fix