implement new version of algorithm