added printing parts to generate_chain