added the code for reversing the alternate node list