Added background and made the code modular