Modularizing the code