move inline js out of view
some code clean up