some refactoring in main module