Add nodes function and test