lots of updates to algorithm