remove dependence on scipy