moving js to module pattern