error handling improve (draft)