moved js to a lib to reuse on both pages