fixes appenChild of null in some cases