moved script inclusion to last and changed event binding scope