Algoritm completed, still need to complete other minor functions