Refactor new node code