partial implementation of chain creation algorithm