make_chains function working