diff --git a/Data/Histogram/Fill.hs b/Data/Histogram/Fill.hs
--- a/Data/Histogram/Fill.hs
+++ b/Data/Histogram/Fill.hs
@@ -1,4 +1,5 @@
-{-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE Rank2Types   #-}
 -- |
 -- Module     : Data.Histogram.Fill
 -- Copyright  : Copyright (c) 2009, Alexey Khudyakov <alexey.skladnoy@gmail.com>
@@ -331,7 +332,9 @@
 -- with histogram filling
 mkFolder :: b -> (a -> b -> b) -> HBuilder a b
 mkFolder a f = HBuilder $ do ref <- newSTRef a
-                             return HBuilderM { hbInput  = \x -> modifySTRef ref (f x)
+                             return HBuilderM { hbInput  = \x -> do acc <- readSTRef ref
+                                                                    let !acc' = f x acc
+                                                                    writeSTRef ref acc'
                                               , hbOutput = readSTRef ref
                                               }
 {-# INLINE mkFolder #-}
diff --git a/histogram-fill.cabal b/histogram-fill.cabal
--- a/histogram-fill.cabal
+++ b/histogram-fill.cabal
@@ -1,5 +1,5 @@
 Name:           histogram-fill
-Version:        0.5.1
+Version:        0.5.1.1
 Cabal-Version:  >= 1.6
 License:        BSD3
 License-File:   LICENSE
