Added exception handling and end-of-listing