extract model generation to separate js file