beter catching of errors