Modify logic from prependTo to appendTo