Added implementation for insertAfter