added the fns used to compose main recursive fn [ci skip]