put a good part of the code in javaScript