added improved error handling