refactored get_nodes