fixed num_nodes calculation