added better error exceptions