added getNthFromEnd