still working on algorithm formatting