refactoring

made it more modular