modified code
code refacterd