cleaned up the view code, moved the script to its own js file