partial code untill adding nodes