fix exception handling and remove debugging line