fixes bug with negative probability