cleaned up program and added clarifying comments.
added node struct