fixed function adding to algorithm