improved js validation