improve error analysis