Javascript: refinements