added more debug around error handling/trapping