Updated to include error analysis function.