extended algorithm to generate bigger chain