moved js to file, still some cleanup to do