maybe put this in ``core/algorithms.py`` ?