implemented deleteNthElement() function