updated code for algos