Software error: Can't call method "appendChild" on an undefined value at