migrate js code to modular architecture