APD-231: Improved js code