replace break with return in insertAtNthPosition method