move code to js