Genralised the code
Merge pull request #2 from pandemanish/master

Genralised the code