improved js structure