start rewriting in Haskell