move add new node logic into its own method