added exception handling and some other output