Finished version 1 with algorithms working