first version with the Python implementation separated out...