added better error messaging