Modularising the code
Fixing issues after modularization