fixing #247 & part of #253