refacted to js files, still need to fix indentation, pull request practice