Refactor recovery of nodes function