added a very fast haskell version