working version, almost 200x faster with f2py