applying some basic styling
transformed into pure javascript, made some code stylistic changes