modularizing the code