improvement on javascript file