Logic enhanced and logger added
Exception handling added
Logic enhanced