working soln for 2-node case