putting together everything in C to run a chain