added a main implementation that doesnt take the first step in outer and inner