Fixed appendChild() to get last child in document