some code refactoring to get rid of code repetition and anonymous funtio...

dude some code refactoring with amazing Haskell.