added calculation for errors, to be complete