further refactoring towards module pattern