refactor to module pattern