added improved error messaging