updated error handle mechanism