modified code to use module pattern