don't need to define function twice
put all js into the same DOM load listener
indent fix