moved the js into a separate file so it can be re-used