Add two node and three node logic