finished error calculation