slight restructure to retain same calling function name as cython / js
versions.