refactored code to use CommonJS modules