fixing add bug and updating display to now loop through the while tree
cleaning up functions slightly