improved logic behind how errors are computed.