part 3 is working though room for improvment in bouth algoritme and effective code