js working
migrate html script to js