handle more errors and change error structure