added code for getting nth/middle node from list