added dictionary , made code modular