moved on click events into js from html