refactored haskell code using hlint