Residual detection