Minor fixes

* js efficiency - moved duplicate code to function
* fixed html error and html layout