heavy refactoring for easier addition of other modules