added error calculation