added error dectections