fixed spelling, added error handling, changed DOM calls