refactoring
modularizing the code