refactoring the Haskell