+ Added the main algorithm