completing error calculation (and a bit of a clean up)