use dynamic number of nodes