changing lib to use module pattern