fix bug where large negative deviations would be erroneously kept