refactored node addition and rendering into seperate functions