Added improved error messaging