Fixed the node preference function