refactoring modules and simplifying the code.