broke out javascript, improved formatting