added reversal of list code