error calculation fix
CD optimizations