javascript script improved