pasted in generate_nodes; not working yet.