added error log and handlers