added better errors to debug