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

pull request practice