changed file to use appendChild, separated out functions, etc.