Modified addLast method