many changes, separated the IO logic from the main loop, made the Algorithm a class and made stop conditions for many algorithms