improvements in error handling