still figuring out haskell syntax. I think this is a bit more readable...