refactored to module pattern