a 'SciPy-free' version