Updates to algorithm