Fitting js code