fixed issues #837 and #380