re-organized the various algorithms for inputs